#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const int maxn = 1e6 + 100;
bool dp[maxn];

/**
 * 素数筛法
 * @param n
 */
void init(ll n) {
    fill(dp, dp + n + 1, true);
    dp[0] = dp[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (dp[i]) {
            for (int j = i * i; j <= n; j += i) {
                dp[j] = false;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b;
    cin >> a >> b;

    init(b);
    cout << count(dp + a, dp + b + 1, true) << endl;
    return 0;
}
